<?php
/**
 * Created by PhpStorm.
 * User: Aliaksei Lazerka
 * Date: 10/9/14
 * Time: 10:31 PM
 */

namespace controller;

use exception\IException;

if (!defined('NYMPH_ROOT')) {
  define('NYMPH_ROOT', dirname("../../../" . __FILE__));
  require(NYMPH_ROOT . '/local/loader/kernel/classes/URLClassLoader.php');
}


class RequestContext
{

  /**
   * @var array request params
   */
  private $objects;

  /**
   * @var array errors
   */
  private $errors;
  /**
   * @var IException[]
   */
  private $exceptions;

  /**
   * @return array
   */
  public function getObjects()
  {
    return $this->objects;
  }

  /**
   * @return array
   */
  public function getErrors()
  {
    return $this->errors;
  }

  /**
   * @param string $key
   * @return mixed
   */
  public function getObject($key)
  {
    return $this->objects[$key];
  }

  /**
   * @param array $objects
   */
  public function setObjects($objects)
  {
    $this->objects = $objects;
  }

  /**
   * @param string $key
   * @param mixed $object
   */
  public function addObject($key, $object)
  {
    $this->objects[$key] = $object;
  }

  /**
   * @param string $name
   * @param string $error
   */
  public function addError($name, $error)
  {
    $this->errors[$name] = $error;
  }

  /**
   * @param IException $exception
   */
  public function addException($exception)
  {
    $this->exceptions[] = $exception;
  }

  /**
   * Error check
   * @return bool
   */
  public function hasErrors()
  {
    return sizeof($this->errors) > 0 ? true : false;
  }

  /**
   * @return IException[]
   */
  public function getExceptions()
  {
    return $this->exceptions;
  }

  /**
   * @param array $exceptions
   */
  public function setExceptions($exceptions)
  {
    $this->exceptions = $exceptions;
  }


} 